//
//  SideMenuViewController.m
//  OurRelaxDemo
//
//  Created by 王雅蓉 on 15/6/28.
//  Copyright (c) 2015年 于宾尧. All rights reserved.
//

#import "SideMenuViewController.h"
#import "RootViewController.h"
#import "SoCangViewController.h"
#import "SettingViewController.h"
#import "AboutUsViewController.h"

@interface SideMenuViewController ()

@property (nonatomic, retain) UITableView *mineTableView;

@end

@implementation SideMenuViewController

-(void)dealloc
{
    [_mineTableView release];
    
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.mineTableView = ({
        UITableView *mineTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, (self.view.frame.size.height - 54 * 5) / 2.0f, self.view.frame.size.width, 54 * 5) style:UITableViewStylePlain];
        mineTableView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleWidth;
        mineTableView.delegate = self;
        mineTableView.dataSource = self;
        mineTableView.opaque = NO;
        mineTableView.backgroundColor = [UIColor clearColor];
        mineTableView.backgroundView = nil;
        mineTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        mineTableView.bounces = NO;
        mineTableView;
    });
    
    [self.view addSubview:_mineTableView];
    
    [_mineTableView release];
    
}

#pragma mark -
#pragma mark UITableView Delegate

//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    [tableView deselectRowAtIndexPath:indexPath animated:YES];
//    
//    switch (indexPath.row) {
//        case 0:
////            [self.sideMenuViewController setContentViewController:[[UINavigationController alloc] initWithRootViewController:[[RootViewController alloc] init]]
////                                                         animated:YES];
////            [self.sideMenuViewController hideMenuViewController];
//            [self.sideMenuViewController setContentViewController:[[UINavigationController alloc] initWithRootViewController:[[SoCangViewController alloc] init]] animated:YES];
//            [self.sideMenuViewController hideMenuViewController];
//            break;
//        case 1:
//            break;
//        default:
//            break;
//    }
//}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    switch (indexPath.row) {
        case 0:
            //            [self.sideMenuViewController setContentViewController:[[UINavigationController alloc] initWithRootViewController:[[RootViewController alloc] init]]
            //                                                         animated:YES];
            //            [self.sideMenuViewController hideMenuViewController];
                        [self.sideMenuViewController setContentViewController:[[UINavigationController alloc] initWithRootViewController:[[SoCangViewController alloc] init]] animated:YES];
                        [self.sideMenuViewController hideMenuViewController];
                        break;
        case 1:
            
            break;
        case 2:
            [self.sideMenuViewController setContentViewController:[[UINavigationController alloc] initWithRootViewController:[[SettingViewController alloc] init]]
                                                         animated:YES];
            [self.sideMenuViewController hideMenuViewController];
        case 3:
            [self.sideMenuViewController setContentViewController:[[UINavigationController alloc] initWithRootViewController:[[AboutUsViewController alloc] init]]
                                                         animated:YES];
            [self.sideMenuViewController hideMenuViewController];
        default:
            break;
    }
}

#pragma mark -
#pragma mark UITableView Datasource

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 54;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
        cell.backgroundColor = [UIColor clearColor];
        cell.textLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:18];
        cell.textLabel.textColor = [UIColor whiteColor];
        cell.textLabel.highlightedTextColor = [UIColor lightGrayColor];
        cell.selectedBackgroundView = [[UIView alloc] init];
    }
    
    NSArray *titles = @[@"我的收藏", @"设置", @"关于我们"];
    NSArray *images = @[@"IconEmpty@2x.png", @"IconEmpty@2x.png", @"IconEmpty@2x.png"];
    cell.textLabel.text = titles[indexPath.row];
    cell.imageView.image = [UIImage imageNamed:images[indexPath.row]];
    
    return cell;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
